'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:PersonnelBdtipCtrl
 * @description
 * # PersonnelBdtipCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
    .controller('PersonnelBdtipCtrl', function ($scope, openApi, Util, $routeParams, FormSubmit) {
        var id = $scope.process_id = $routeParams.id
        $scope.submit = function (operationId) {

            // 底部类型end
            var options = {};
            // 流程id
            options.id = id;
            // 根据operationId判断是草稿还是提交
            options.operationId = operationId;
            options.urlParam = openApi.bdApply;
            options.param = angular.copy($scope.param, {});
            FormSubmit.submit(options,$scope);
        };
        $scope.validate = function () {
            if (!$scope.param.startBdDate) {
                Util.Toast("请选择起始日期");
                return;
            }
            if (!$scope.param.endBdDate) {
                Util.Toast("请选择截至日期");
                return;
            }
            if (!$scope.param.bdDays) {
                Util.Toast("请填写补登天数");
                return;
            }
            if (!Util.checkDays($scope.param.bdDays)) {
                Util.Toast("补登天数要为0.5的倍数");
                return;
            }
            if (!$scope.param.reason) {
                Util.Toast("请填写补登原因");
                return;
            }
            if (!$scope.validation.passvalidation) {
                Util.Toast($scope.validation.tip);
                return;
            }
            return true;
        }
        var init = function () {
            // 获取回显的详细信息
            Util.getDetailData(id, function (data) {
                $scope.param = data;
            });
        };
        // 初始化
        init();

    });
